import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter/material.dart';



void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: HomePage(),
    );
  }
}

bool HaveTx = false;
String ImgUrl = '';

class HomePage extends StatefulWidget {
  @override
  HomePageState createState() => new HomePageState();
}

class HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color.fromRGBO(236, 236, 236, 1),
      appBar: AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(
                      Icons.arrow_back_ios,
                      color: Colors.white,
                    ),
                    Text(
                      '返回',
                      style: TextStyle(color: Colors.white, fontSize: 16),
                    )
                  ],
                ),
                onPressed: () {},
              ),
              Container(
                child: Row(
                  children: [
                    Text(
                      '抢单待确认详情',
                      style: TextStyle(fontSize: 16),
                    ),
                    SizedBox(
                      width: 25,
                    )
                  ],
                ),
              ),
              IconButton(icon: Icon(Icons.more_horiz), onPressed: () {})
            ],
          )),
      body: Container(
        child: Column(
          children: <Widget>[
            //跑腿待付款（金额内容地址）
            Container(
              padding:
                  EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  //跑腿待付款
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(
                        "跑腿",
                        style: TextStyle(fontSize: 14),
                      ),
                      Spacer(),
                      Text(
                        "待确认",
                        style: TextStyle(color: Colors.red, fontSize: 16),
                        textAlign: TextAlign.right,
                      )
                    ],
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  Text(
                    "任务主题（限制20字）",
                    style: TextStyle(fontSize: 18),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Row(
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                          border: Border.all(width: 1),
                          borderRadius: BorderRadius.circular(75),
                        ),
                        width: 60,
                        height: 60,
                        child: Tx(),
                      ),
                      SizedBox(width: 10,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text("发单人姓名", style: TextStyle(fontSize: 16)),
                          Text("福建省厦门市（发单人地址）", style: TextStyle(fontSize: 14)),
                        ],
                      )
                    ],
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  //已支付
                  Row(
                    children: <Widget>[
                      Padding(
                        padding: EdgeInsets.only(right: 5),
                        child: Icon(
                          Icons.attach_money,
                          color: Color.fromRGBO(51, 51, 51, 0.5),
                        ),
                      ),
                      Text("跑腿费：4元", style: TextStyle(fontSize: 16))
                    ],
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  //任务内容
                  Container(
                    width: 300,
                    child: Row(
                      children: <Widget>[
                        Icon(
                          Icons.message,
                          color: Color.fromRGBO(51, 51, 51, 0.5),
                        ),
                        Expanded(
                          child: Padding(
                            padding: EdgeInsets.only(left: 5, top: 12),
                            child: Text(
                              '任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容',
                              style: TextStyle(fontSize: 16),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  //发单人电话
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Icon(
                        Icons.phone_android,
                        color: Color.fromRGBO(51, 51, 51, 0.5),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 5, top: 5),
                        child:
                            Text("13988888888", style: TextStyle(fontSize: 16)),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 15,
                  ),
                  //电话发单人
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(
                        Icons.phone,
                        color: Color.fromRGBO(51, 51, 51, 0.5),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 20, bottom: 5),
                        child: Text("电话接单人", style: TextStyle(fontSize: 16)),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 25,
                  ),
                  //  发布时间
                  Row(
                    children: <Widget>[
                      Icon(
                        Icons.access_time,
                        color: Color.fromRGBO(51, 51, 51, 0.5),
                      ),
                      Padding(
                          padding: EdgeInsets.only(left: 0),
                          child: Text("  发布时间：2017-6-20 18:00",
                              style: TextStyle(fontSize: 16))),
                    ],
                  ),
                  SizedBox(
                    height: 5,
                  ),
                  //接单时间
                  Padding(
                    padding: EdgeInsets.only(left: 31),
                    child: Text("接单时间：2017-6-20 19:00",
                        style: TextStyle(fontSize: 16)),
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  //  接单人姓名
                  Row(
                    children: <Widget>[
                      Icon(
                        Icons.location_on,
                        color: Color.fromRGBO(51, 51, 51, 0.5),
                      ),
                      Padding(
                          padding: EdgeInsets.only(left: 5),
                          child: Text("接单人姓名    15688888888 ",
                              style: TextStyle(fontSize: 16))),
                    ],
                  ),
                ],
              ),
              decoration: BoxDecoration(color: Colors.white),
            ),
            Spacer(),
            //取消订单
            Container(
              child: Row(
                // mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Padding(
                    padding: EdgeInsets.only(
                        left: 10,
                        right: MediaQuery.of(context).size.width * 0.3),
                    child: GestureDetector(
                      onTap: () {
                        showDialog(
                            context: context,
                            barrierDismissible: false,
                            builder: (BuildContext context) {
                              return SSDialog();
                            });
                      },
                      child: Container(
                        margin: EdgeInsets.only(right: 5),
                        decoration: new BoxDecoration(
                            border: new Border.all(color: Colors.grey, width: 0.5),
                            color: Colors.grey,
                            borderRadius: new BorderRadius.circular((5.0))),
                        alignment: Alignment.center,
                        width: 80,
                        height: 36,
                        child: Text(
                          '申诉',
                          textAlign: TextAlign.center,
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                    ),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      GestureDetector(
                        onTap: () {
                          showDialog(
                              context: context,
                              barrierDismissible: false,
                              builder: (BuildContext context) {
                                return QXDialog();
                              });
                        },
                        child: Container(
                          margin: EdgeInsets.only(right: 5),
                          decoration: new BoxDecoration(
                              border: new Border.all(color: Colors.grey, width: 0.5),
                              color: Colors.grey,
                              borderRadius: new BorderRadius.circular((5.0))),
                          alignment: Alignment.center,
                          width: 80,
                          height: 36,
                          child: Text(
                            '取消接单',
                            textAlign: TextAlign.center,
                            style: TextStyle(color: Colors.white),
                          ),
                        ),
                      ),
                      GestureDetector(
                        onTap: () {
                          showDialog(
                              context: context,
                              barrierDismissible: false,
                              builder: (BuildContext context) {
                                return KSDialog();
                              });
                        },
                        child: Container(
                          margin: EdgeInsets.only(right: 5),
                          decoration: new BoxDecoration(
                              border: new Border.all(color: Colors.grey, width: 0.5),
                              color: Colors.grey,
                              borderRadius: new BorderRadius.circular((5.0))),
                          alignment: Alignment.center,
                          width: 80,
                          height: 36,
                          child: Text(
                            '开始任务',
                            textAlign: TextAlign.center,
                            style: TextStyle(color: Colors.white),
                          ),
                        ),
                      ),
                    ],
                  )
                ],
              ),
              height: 50,
              color: Colors.white,
            ),
          ],
        ),
      ),
    );
  }
}
//头像判断
Tx() {
  if (HaveTx == false) {
    return Center(
      child: Text('头像',textAlign:TextAlign.center,),
    );
  } else {
    return Image.asset(
      ImgUrl,
      fit: BoxFit.fill,
    );
  }

}
void alertdialog(){
  Timer timer=new Timer(Duration(seconds: 1), (){
    AlertDialog(
      title: Text("提示"),
      actions: <Widget>[
        Text("我我我我偶无无无无无")
      ],
    );
  });
}


//申诉弹窗
class SSDialog extends StatefulWidget {
  @override
  SSDialogState createState() => new SSDialogState();
}
class SSDialogState extends State<SSDialog> {
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 300.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: <Widget>[
                    Container(
                      child: FlatButton(
                        color: Colors.white,
                        child: Icon(Icons.close),
                        onPressed: (){
                          Navigator.of(context, rootNavigator: true).pop();
                        },
                      ),
                      height: 40,
                      width: 40,
                      margin: EdgeInsets.only(right: 10),
                      decoration: BoxDecoration(
                          border: new Border.all(color: Colors.white, width: 1),
                          borderRadius: BorderRadius.all(Radius.circular(50)),
                          color: Colors.white
                      ),
                    )
                  ],
                ),
                Container(
                  child: Text("如果出现争议，请拨打下方客服电话进行申诉",textAlign: TextAlign.center,),
                  margin: EdgeInsets.all(35),
                ),
                Container(
                  child: Text("客服电话：0492-4888888",textAlign: TextAlign.center,style: TextStyle(color: Colors.blue),),
                  margin: EdgeInsets.only(left: 40,right: 40),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}


//取消接单弹窗
class QXDialog extends StatefulWidget {
  @override
  QXDialogState createState() => new QXDialogState();
}
class QXDialogState extends State<QXDialog> {
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 300.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: <Widget>[
                    Container(
                      child: FlatButton(
                        color: Colors.white,
                        child: Icon(Icons.close),
                        onPressed: (){
                          Navigator.of(context, rootNavigator: true).pop();
                        },
                      ),
                      height: 40,
                      width: 40,
                      margin: EdgeInsets.only(right: 10),
                      decoration: BoxDecoration(
                          border: new Border.all(color: Colors.white, width: 1),
                          borderRadius: BorderRadius.all(Radius.circular(50)),
                          color: Colors.white
                      ),
                    )
                  ],
                ),
                Container(
                  child: Text("不能私下取消跑单哦，如确有需要，请联系客服跑腿！",textAlign: TextAlign.center,),
                  margin: EdgeInsets.all(35),
                ),
                Container(
                  child: Text("客服电话：0492-4888888",textAlign: TextAlign.center,style: TextStyle(color: Colors.blue),),
                  margin: EdgeInsets.only(left: 40,right: 40),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }

}


//开始任务弹窗
class KSDialog extends StatefulWidget {
  @override
  KSDialogState createState() => new KSDialogState();
}

class KSDialogState extends State<KSDialog> {
  @override
  Widget build(BuildContext context) {
    return  Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 320.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                SizedBox(height: 10,),
                Text("确认提示",style: TextStyle(fontSize: 16),),
                SizedBox(height: 40,),
                Padding(
                    padding: EdgeInsets.all(0),
                    child: Center(
                      child: Text("开始任务后需尽快完成任务，确认开始任务吗？",style: TextStyle(fontSize: 20),textAlign: TextAlign.center,),
                    )
                ),

                Spacer(),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("确认"),
                            onPressed: (){
                              Navigator.pop(context);
                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                    ,
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor:Color.fromRGBO(255,255,255,0),
                            child: Text("取消"),
                            onPressed: (){
                              Navigator.pop(context);
                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border: new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                  ],
                ),

              ],
            ),
          ),
        ),
      ),
    );
  }
}
